package com.nopay.dxdwphone.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.nopay.dxdwphone.R;

public class DialogDeleteCallTask extends Dialog {

    public DialogDeleteCallTask(@NonNull Activity context) {
        super(context, R.style.MyDialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_delete_call_task);

        findViewById(R.id.tv_dialog_cancel).setOnClickListener(v -> dismiss());
        findViewById(R.id.tv_dialog_confirm).setOnClickListener(v -> {
            dismiss();
            if(onDeleteCallTaskConfirmListener != null) onDeleteCallTaskConfirmListener.onDeleteCallTaskConfirm();
        });
    }

    public void show(String tipsContent) {
        super.show();
        TextView tvTipsContent = findViewById(R.id.tv_tipsContent);
        tvTipsContent.setText(tipsContent);
    }

    @Override
    public void dismiss() {
        super.dismiss();
        TextView tvTaskName = findViewById(R.id.tv_task_name);
        tvTaskName.setText("");
    }

    private OnDeleteCallTaskConfirmListener onDeleteCallTaskConfirmListener;

    public DialogDeleteCallTask setOnDeleteCallTaskConfirmListener(OnDeleteCallTaskConfirmListener onDeleteCallTaskConfirmListener) {
        this.onDeleteCallTaskConfirmListener = onDeleteCallTaskConfirmListener;
        return this;
    }

    public interface OnDeleteCallTaskConfirmListener {

        void onDeleteCallTaskConfirm();
    }
}
